const apple = (payid, orderid) => {
	plus.payment.getChannels((channels) => {
		for (var i in channels) {
			var channel = channels[i];
			if (channel.id == 'appleiap') {
				let iap = channel;
				iap.requestOrder([payid], (orderList) => {
					console.log('requestOrder success: ' + JSON.stringify(orderList))
					applePay(orderList[0], orderid)
				}, (e) => {
					uni.showToast({
						title: '暂不支持苹果iap支付',
						icon: 'none',
						duration: 1000
					});
				});
			}
		}
	})
}
const applePay = (para, orderid) => {
	setTimeout(() => {
		uni.hideToast()
	}, 1000)
	uni.requestPayment({
		provider: 'appleiap',
		orderInfo: {
			productid: para.productid,
			username: orderid,
			optimize: true
		},
		success: (es) => {
			uni.showToast({
				title: '支付成功了',
				icon: 'none',
				duration: 1000
			});
		},
		fail: (err) => {
			uni.showToast({
				title: '取消支付',
				icon: 'none',
				duration: 1000
			});
		}
	})
}
export default {
	apple
}